package demo.ui;

import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class FormLogin extends JFrame{
	
	private JTextField tfUsername;
	private JTextField tfPassword;
	private JButton btnLogin, btnCancel;
	
	public FormLogin(){
		super("Login into system");
		initComponent();
		
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e){
				System.exit(0);
			}
		});
	}
	
	private void initComponent(){
		setBounds(10, 20, 210, 120);
		Container c = this.getContentPane();
		c.setLayout(new GridLayout(3, 1));
		
		JPanel pnUsername = new JPanel();
		JLabel lbUsername = new JLabel("Username");
		tfUsername = new JTextField(10);
		pnUsername.add(lbUsername);
		pnUsername.add(tfUsername);
		c.add(pnUsername);
		
		JPanel pnPass = new JPanel();
		JLabel lbPass = new JLabel("Password");
		tfPassword = new JTextField(10);
		pnPass.add(lbPass);
		pnPass.add(tfPassword);
		c.add(pnPass);
		
		JPanel pnButtons = new JPanel();
		btnLogin = new JButton("Login");
		
		
		btnLogin.addActionListener(new ActionListener(){

			@Override
			public void actionPerformed(ActionEvent arg0) {
				System.out.println("Ban vua nhan len button Login");
			}
			
		});
		
		
		btnCancel = new JButton("Cancel");
		pnButtons.add(btnLogin);
		pnButtons.add(btnCancel);
		c.add(pnButtons);
	}
}